Skip to content

compilers: fix clang-cl cross without setting many args on cc - #15367

Merged
dcbaker merged 2 commits into
mesonbuild:masterfrom
mcha-forks:mochaa/clang-cl-cross
Jun 4, 2026
Merged

dcbaker merged 2 commits into
mesonbuild:masterfrom
mcha-forks:mochaa/clang-cl-cross

Conversation

@mochaaP

@mochaaP mochaaP commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

See the expanded commit messages for explanations.

Before:

[binaries]
c = ['clang-cl', '--target=' + target, '-fuse-ld=lld', '/winsysroot', root]
cpp = ['clang-cl', '--target=' + target, '-fuse-ld=lld', '/winsysroot', root]
# c_ld not set
# cpp_ld not set

After:

[binaries]
c = ['clang-cl', '--target=' + target]
cpp = ['clang-cl', '--target=' + target]
c_ld = 'lld-link'
cpp_ld = 'lld-link'

The detect_vs_dep_prefix change needs more testing. I tested this on:

  • msvc-wine's wrapper
  • native windows msvc
  • clang-cl on linux

Closes #15851

@mochaaP
mochaaP force-pushed the mochaa/clang-cl-cross branch from da492cb to bd3e854 Compare December 9, 2025 20:59
mochaaP added 2 commits May 28, 2026 02:52
normal compilers does not rely on the position of this argument,
but MSVC-like compilers treat `/link` and any argument after that
as linker arguments. MSVC-like compiler's linker_to_compiler_args
inject `/link` before largs, resulting it being forwarded to link.exe
not the compiler driver.

fixes cross compiling with cc = clang-cl and c_ld = lld-link.
this function does not pass enough args from the compiler object to find
windows sdk without relying on environment variables.
including a file from the same directory removes the dependency on stdlib.
@mochaaP

mochaaP commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

rebased

@dcbaker

dcbaker commented May 27, 2026

Copy link
Copy Markdown
Member

I'm not going to claim I'm an expert at this, but the code looks reasonable.

@dcbaker dcbaker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm giving an approve, if no one else chimes in with concerns I'll plan to merge this next week.

@dcbaker dcbaker added this to the 1.12 milestone May 27, 2026
@dcbaker
dcbaker merged commit 1e50fe1 into mesonbuild:master Jun 4, 2026
29 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants